package Review05;

public class Master {

    public void cure(Pet pet){
       pet.gotoHospital();
    }

    public Pet adopt(String type){
        if ("狗".equals(type)){
            return new Dog("h",100,100,"哈士奇");
        }
        if ("企鹅".equals(type)){
            return new Penguin("q",100,100,"熊");
        }
        return null;
    }

    public void play01(Pet pet){
        if (pet instanceof Dog){
            Dog d1 = (Dog) pet;
            d1.play();
        }
        if (pet instanceof Penguin){
            Penguin p1 = (Penguin) pet;
            p1.swim();
        }
    }
}
